package com.timebank.score.controller;

import com.timebank.common.core.web.controller.BaseController;
import com.timebank.common.core.web.page.TableDataInfo;
import com.timebank.common.core.web.pojo.AjaxResult;
import com.timebank.common.security.annotation.InnerAuth;
import com.timebank.common.security.annotation.RequiresLogin;
import com.timebank.score.pojo.entity.ScoreTaskLog;
import com.timebank.score.service.ScoreTaskLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 积分任务记录 控制层
 * @author shiliuyinzhen
 */
@RestController
@RequestMapping("/taskLog")
@Api(tags = "积分任务记录")
public class ScoreTaskLogController extends BaseController {

    @Resource
    private ScoreTaskLogService scoreTaskLogService;

    /**
     * 查询任务记录列表
     *
     * @param scoreTaskLog
     * @return
     */
    @RequiresLogin
    @GetMapping("/list")
    @ApiOperation("查询任务记录列表")
    public TableDataInfo getScoreTaskLogList(ScoreTaskLog scoreTaskLog){
        startPage();
        List<ScoreTaskLog> list = scoreTaskLogService.getScoreTaskLogList(scoreTaskLog);
        return getDataTable(list);
    }

    /**
     * 新增积分任务记录,如果存在就更新
     * @param scoreTaskLog
     * @return
     */
    @InnerAuth
    @PostMapping
    @ApiOperation("新增积分任务记录")
    public AjaxResult addScoreTaskLog(@RequestBody ScoreTaskLog scoreTaskLog){
        return scoreTaskLogService.addScoreTaskLog(scoreTaskLog);
    }

}
